package com.weiqiao.mall.repository.impl;

import com.weiqiao.base.dao.impl.BaseMongoDaoImpl;
import com.weiqiao.mall.repository.ITeamRepository;
import org.bson.Document;
import org.bson.conversions.Bson;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository("TeamRepositoryImpl")
public class TeamRepositoryImpl extends BaseMongoDaoImpl implements ITeamRepository {
    private final static String collectionName = "team_";

    @Override
    public List<String> teamList(Bson filter, Bson sort, int skip, int limit, int company_id) {
        return super.findFilterSortSkipLimit(collectionName + company_id, filter, sort, skip, limit);
    }

    @Override
    public Boolean updateTeam(Bson filter, Document doc, int company_id) {
        return super.updateOne(collectionName + company_id, filter, doc, false);
    }

    @Override
    public Boolean insertTeam(String json, int company_id) {
        return super.inSert(collectionName + company_id, json);
    }

    @Override
    public Boolean deleteTeam(Bson filter, Document doc, int company_id) {
        return super.updateOne(collectionName + company_id, filter, doc, false);
    }

    @Override
    public int countTeam(int company_id, Bson filters) {
        return super.statististics(collectionName + company_id, filters);
    }

    @Override
    public List<String> notLeaderList(Bson filters, int company_id) {
        return super.findFilter(collectionName + company_id, filters);
    }

    @Override
    public List<String> getList(Bson filters, int company_id) {
        return super.findFilter(collectionName + company_id, filters);
    }

    @Override
    public String findOne(int company_id, Bson filters) {
        return this.findOne(collectionName + company_id, filters);
    }
}
